package customerEnter.Frame.ehcache.Judge;

import java.util.HashMap;
import java.util.Map;

import customerEnter.Frame.ehcache.AvailableEhcache.EcacheDataTransmission;
import customerEnter.Frame.ehcache.AvailableEhcache.EcacheParameterSet;
import customerEnter.tool.WhetherToEmpty;

@SuppressWarnings({ "unchecked", "deprecation", "static-access" })
public class MapEcache {
	private static MapEcache			MapEcache;
	private static Map<String, Object>	setMap;
	private static String				eachName;

	private MapEcache() {
		Initializati();
	}

	private void Initializati() {
		if (!WhetherToEmpty.ObjectWhetherToEmpty(setMap)) {
			setMap = new HashMap<String, Object>();
		}
		try {
			setMap = (Map<String, Object>) EcacheDataTransmission.getEcacheDataTransmission().getElementEach(eachName)
					.getValue();

		} catch (Exception e) {
			setMap = new HashMap<String, Object>();
		}
	}

	public static MapEcache getMapEcache(String eachName) {
		MapEcache.eachName = eachName;
		MapEcache = new MapEcache();
		return MapEcache;
	}

	private static void SetDataIf(String key, Object Judge) {
		setMap.put(key, Judge);
		EcacheParameterSet.getEcacheParameterSet().addEach(eachName, setMap);
	}

	private static Object GetDataIf(String key) {
		return setMap.get(key);
	}

	/**
	 * 設置
	 */
	public static void setEachMap(String key, Object object) {
		SetDataIf(key, object);
	}

	/**
	 * 獲取
	 */
	public static Object getEachMap(String key) {
		return GetDataIf(key);
	}

}
